package com.qf.controller;/*
@author fu
@date 2022/3/2816:38
*/

import com.qf.pojo.ResponseData;
import com.qf.pojo.User;
import com.qf.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")
public class UserController {

    //注入service
    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    @ResponseBody
    public ResponseData login(String username, String password,HttpSession session){

        System.out.println(username);
        System.out.println(password);

       /* User user = userService.isLogin(username);
        String pwd = user.getPassword();*/
       User user =new User();

        if (password==null){
            //提示错误的消息
            return new ResponseData(0,"用户名或者密码错误");
        }
        if (!password.equals(user.getPassword())){

            return new ResponseData(0,"用户名或者密码错误");
        }

        //将用户名存储到session域中
        session.setAttribute("username",username);

        return new ResponseData(1,"恭喜您,登录成功!");
    }
}
